import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:provider/provider.dart';
import 'view/home_view.dart';
import 'service/book_provider.dart';
import 'service/book_api_service.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  //await Firebase.initializeApp();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  final BookApiService apiService = BookApiService();

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (_) => BookProvider(apiService: apiService),
        ),
      ],
      child: MaterialApp(
        title: '图书管理',
        theme: ThemeData(
          primarySwatch: Colors.blue,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        home: HomeScreen(),
      ),
    );
  }
}

//class MyApp extends StatelessWidget {
//  final BookApiService apiService = BookApiService();
//
//  @override
//  Widget build(BuildContext context) {
//    return MultiProvider(
//      providers: [
//        ChangeNotifierProvider(create: (_) => BookProvider()),
//      ],
//      child: MaterialApp(
//        title: '图书管理',
//        theme: ThemeData(
//          primarySwatch: Colors.blue,
//          visualDensity: VisualDensity.adaptivePlatformDensity,
//        ),
//        home: HomeScreen(),
//      ),
//    );
//  }
//}